Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Dynamic submenus

0.00/5 (No votes)
20 Mar 2000 1  
Some handy functions for adding and deleting submenus and menuitems in runtime

Sample Image - DynMenu.gif

Here are some short handy functions for adding and deleting submenus and menu items in runtime.

To add a menu with some items in the file menu at a specified index, use:

MenuItemData data[] ={
  ID_COMMAND_1, "First Item",
  ID_COMMAND_2, "Second Item",
  0, NULL
};
CMenu *pMenu = AddSubMenu(pMainFrm, file_menu_index, sub_menu_index, "Dynamic Menu", data);

To append an item to the menu later on, use:

AddSubMenuItem(pMenu, ID_COMMAND_3, "Third Item");

To remove a submenu again, use:

RemoveSubMenu(pMainFrm, file_menu_index, sub_menu_index);

To remove only one item, use:

RemoveSubMenuItem(pMenu, ID_COMMAND_1);

That's all. Enjoy!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below.

A list of licenses authors might use can be found here.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here